package com.yst.gateway.monitor.common.utils;

import java.io.IOException;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * json转换工具类
 * @author sheungxin
 *
 */
public class JsonUtils {
	
	public static <T> T parse(String jsonStr,Class<T> t) throws JsonParseException, JsonMappingException, IOException{
		return new ObjectMapper().readValue(jsonStr, t);
	}
	
	public static <T> String format(T t) throws JsonProcessingException{
		return new ObjectMapper().writeValueAsString(t);
	}
}
